<?php namespace App\Infra;

use App\Models\Address;

use App\Utils\ModelOperatorTrait;

class AddressManager{

	use ModelOperatorTrait;

	public function getAddresses($conditions,$first = false){
		return $this->findModel(Address::class,Address::query(),$conditions,$first)->orderBy('created_at','desc');
	}

	public function createAddress($data){
		return $this->create(Address::class,$data);
	}

	public function updateAddress($id,$data){

		$address = Address::find($id);

		$address->update($data);

		return $address;
	}

	public function deleteAddress($id){
		$address = Address::find($id);

		$address->delete();

		return $address;
	}
}